package javacafe.serviceimple;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javacafe.dao.MemberDAO;
import javacafe.daoimpl.MemberDAOImple;
import javacafe.dto.member.LoginInfoDTO;
import javacafe.dto.member.MemberDTO;
import javacafe.dto.member.UpdateMembersAuthDTO;
import javacafe.service.MemberService;

public class MemberServiceImple implements MemberService {
	
	private MemberDAO memberDAO;
	private static MemberServiceImple memberService;
	
	private MemberServiceImple() {		
		memberDAO = new MemberDAOImple();
	}
	
	public static MemberServiceImple getInstance(){
		if (memberService==null) {
			memberService=new MemberServiceImple();
		}
		return memberService;
	}

	public void setMemberDAO(MemberDAO memberDAO) {
		this.memberDAO = memberDAO;
	}
		
	@Override
	public MemberDTO getMember(MemberDTO dto) {
		return memberDAO.getMember(dto);
	}
	
	@Override
	public boolean insertMember(MemberDTO dto) {
		return memberDAO.insertMember(dto);
	}

	@Override
	public boolean updateMember(MemberDTO dto) {
		return memberDAO.updateMember(dto);
	}

	@Override
	public LoginInfoDTO getLoginInfo(String id, String password) {
		Map<String, String> map = new HashMap<String, String>();
		map.put("m_id", id.trim());
		map.put("m_password", password.trim());		
		return memberDAO.getLoginInfo(map);
	}

	@Override
	public List getAllMember() {
		return memberDAO.getAllMember();
	}

	@Override
	public List getSerchMember(MemberDTO dto) {
		return memberDAO.getSerchMember(dto);
	}
	
	@Override
	public boolean updateAuthMember(UpdateMembersAuthDTO dto) {
		return memberDAO.updateAuthMember(dto);
	}
	
	@Override
	public boolean insertAuthMember(MemberDTO dto) {
		return memberDAO.insertAuthMember(dto);
	}

}
